<template>
<div class="wrapper">
  <swiper :options="swiperOption" v-if="showSwiper">
    <swiper-slide v-for="item of swiper" :key="item.id">
      <img class="swiper_img" :src="item.imgUrl"/>
    </swiper-slide>
    <div class="swiper-pagination"  slot="pagination"></div>
</swiper>
</div>
</template>

<script>
export default {
  name: 'Homeswiper',
  props: {
    swiper: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true,
        autoplay: 2600
      }
    }
  },
  computed: {
    showSwiper () {
      return this.swiper.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  /*全局改变样式的时候这么写 >>> */
  .wrapper >>> .swiper-pagination-bullet-active
    background: white!important
  .wrapper >>> .swiper-container-horizontal > .swiper-pagination-bullets
    bottom: 0.12rem
  .wrapper
    width: 100%
    height: 0
    overflow: hidden
    padding-bottom:37.07%
    background: #eee
    .swiper_img
     width: 100%
</style>
